package cn.lili.modules.payment.client;

import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.constant.ServiceConstant;
import cn.lili.modules.payment.entity.dos.*;
import cn.lili.modules.payment.entity.dto.*;
import cn.lili.modules.payment.entity.vo.OutOrderLogVO;
import cn.lili.modules.payment.fallback.PaymentFallback;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 物流配置客户端
 *
 * @author Chopper
 * @version v1.0
 * 2021-11-08 09:52
 */
@FeignClient(path = "${server.servlet.context-path}", name = ServiceConstant.PAYMENT_SERVICE, contextId = "payment", fallback = PaymentFallback.class)
public interface PaymentClient {


    /**
     * 支付基础信息返回，包含支付支持类目，钱包余额等
     *
     * @return 支付基础信息
     */
    @GetMapping("/feign/payment/base")
    CashierParam base(@RequestParam String paymentClientType);

    /**
     * 生成支付表单
     *
     * @param payParam 支付参数
     * @return 支付表单
     */
    @PostMapping("/feign/payment/generate-payment-form")
    ResultMessage<Object> generatePaymentForm(@RequestBody PayParam payParam);

    /**
     * 线下收款
     */
    @PostMapping("/feign/payment/offline")
    void offlinePay(@RequestBody PayParam payParam);


    /**
     * 流水补缴
     * ps:当订单由于某些原因导致支付金额不足分账需求时，调用此接口协调支付金额
     * 例如极端案例：供应商发布商品100元，平台发布优惠券50元且全部平台承担、店铺发布满减活动满50减50活动，当商品以原价销售时，平台与店铺需分别补缴50元给供应商
     *
     * @param subsidiesParams 补差参数
     */
    @PostMapping("/feign/payment/subsidies")
    PaymentSubsidies subsidies(@RequestBody SubsidiesParams subsidiesParams);

    /**
     * 退款
     *
     * @param refundParam 退款参数
     * @return 退款结果
     */
    @PostMapping("/feign/payment/refund")
    RefundLog refund(@RequestBody RefundParam refundParam);


    /**
     * 支付回查
     */
    @PostMapping("/feign/payment/back/check")
    void everyMinuteExecute();


    /**
     * 支付每日任务
     */
    @PostMapping("/feign/payment/everyDayTask")
    void everyDayTask();

    /**
     * 分账请求
     *
     * @param profitSharingRequestDTO 分账请求参数
     * @return
     */
    @PostMapping("/feign/payment/profitSharing")
    OutOrderLogVO profitSharing(@RequestBody ProfitSharingRequestDTO profitSharingRequestDTO);

    /**
     * 微信账单
     */
    @PostMapping("/feign/payment/wechatBill")
    void wechatBill();

    /**
     * 城市站点审核费用分佣
     *
     * @param params 分佣参数
     */
    @PostMapping("/feign/payment/urbanSubstationCommission")
    PaymentUrbanSubstationCommission urbanSubstationCommission(@RequestBody UrbanSubstationCommissionParams params);

    /**
     * 生成支付场景表单
     *
     * @param payParam 支付参数
     * @return 支付表单
     */
    @PostMapping("/feign/payment/generate-payment-scene-form")
    ResultMessage<Object> generatePaymentSceneForm(@RequestBody PayParam payParam);


    @PostMapping("/feign/memberCastellan")
    @ApiOperation("处理城主打款绿色积分")
    ResultMessage<Object> memberCastellan(@RequestBody UserPointUpdateDTO userPointUpdateDTO);

    /**
     * 根据合单支付号码查询合单支付
     *
     * @param combineOutTradeNo 合单支付号码
     * @return 合单支付
     */
    @GetMapping("/feign/payment/getCombinePaymentLogByCombineOutTradeNo")
    CombinePaymentLog getCombinePaymentLogByCombineOutTradeNo(@RequestParam String combineOutTradeNo);

    @GetMapping("/feign/payment/getPaymentLogByOrderSN")
    @ApiOperation("根据ordersn获取支付日志paymentLog")
    PaymentLog getPaymentLogByOrderSN(@RequestParam String orderSN);

    @PostMapping("/feign/memberUnion")
    @ApiOperation("处理运营中心打款绿色积分")
    ResultMessage<Object> memberUnion(@RequestBody UserPointUpdateDTO userPointUpdateDTO);
}
